package com.taihe.controller;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageInfo;
import com.taihe.domain.SysUser;
import com.taihe.service.SysUserService;
import com.taihe.util.R;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * Created by zwt09 on 2018/12/3.
 */
@Controller
@RequestMapping("/sys/user")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    /**
     * 所有用户列表
     */
    @RequestMapping("/list")
    @ResponseBody
    public R list(@RequestBody Map<String, Object> params){
        List<SysUser> sysUserList = sysUserService.queryPage(params);
        PageInfo<SysUser> page = new PageInfo<>(sysUserList);
        return R.ok().put("page", page);
    }

    @RequestMapping("toList")
    public String toList(){
        return "list";
    }

    public static void main(String[] args) {
        Map<String, Object> params = new HashedMap();
        params.put("username","");
        params.put("page",1);
        params.put("limit",10);
        String s = JSON.toJSONString(params);
        System.out.println(s);
    }








}
